package com.foreknow.controller;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class GetMethodServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        PrintWriter out = resp.getWriter();
        //获取url地址
        String str = req.getServletPath();
        //out.println(str);
//        String[] strings = str.split("/");
//        for (int i=0;i < strings.length;i++){
//            out.println(strings[i]);
//        }
        String clsname = str.substring(1,str.lastIndexOf("/"));
        String leiname = str.substring(str.lastIndexOf("/")+1);
        out.println(clsname +"---"+leiname);
        System.out.println("信息");

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
